package com.itheima.day06;

import java.util.*;

public class Demo4 {
    public static void main(String[] args) {
        //八十个人的选择
        String[] selects={"A","B","C","D"};
        StringBuilder sb=new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < 80; i++) {
            int randomIndex = random.nextInt(selects.length);
            sb.append(selects[randomIndex]);
        }
        System.out.println("sb = " + sb);
        //统计每个景点的人数
        Map<Character,Integer> nums=new HashMap<>();
        for (int i = 0; i < sb.length(); i++) {
            char c = sb.charAt(i);
            if (nums.containsKey(c)) {
                nums.put(c, nums.get(c)+1);
            }else {
                nums.put(c,1);
            }
        }
        System.out.println(nums);

        nums.keySet().stream();
        nums.values().stream();
    }
}
